﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using System.Data.SqlClient;
using BLL;
public partial class Forget : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
         
    }
    protected void showquestion_Click(object sender, EventArgs e)
    {
        UserInfoManager m=new UserInfoManager ();
        if (m.isExists(Txtname.Text.Trim().ToString()))
        {
            DataTable dt=new DataTable ();
            dt=m.find(Txtname.Text.Trim().ToString());
             question.Text=dt.Rows[0]["Ui_question"].ToString ();
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(),  "message", "<script language='javascript' defer>alert('用户名不存在！');</script>");
        }
    }
    protected void find_Click(object sender, EventArgs e)
    {
        UserInfoManager m = new UserInfoManager();
        DataTable dt=new DataTable ();
        dt=m.find(Txtname.Text.Trim().ToString());
        if (answer.Text.Trim().ToString() == dt.Rows[0]["Ui_answer"].ToString ())
        {
            string mm1=SecretManager.Decrypt (dt.Rows[0][1].ToString ());
            mm.Text = "密码是" +mm1;

        }
        else
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('答案错误！');</script>");
        }
    }
}
